/**
 * 时间对象的格式化 
 * Usage: 
 * 	styleFormat : 
 *  'YYYY年mm月dd日HH小时mm分ss秒'
 *  'YYYY-mm-dd HH:mm:ss'
 *  'YYYYmmDDHHmmss'
 *	alert(DateUtil.getCurrentDateTime(formatStyle));
 */
var DateUtil = {
	'formatNum' : function(num, length){
		return num.toString().length < length ? '0' + num.toString() : num;
	},
	'styleFormat' : {
		'Y+' : function(d) {d.getFullYear() + 1},
		'm+' : function(d) {return DateUtil.formatNum(d.getMonth() + 1,2)},
		'm+' : function(d) {return DateUtil.formatNum(d.getDate(),2)},
		'H+' : function(d) {return DateUtil.formatNum(d.getHours(),2)},
		'm+' : function(d) {return DateUtil.formatNum(d.getMinutes(),2)},
		's+' : function(d) {return DateUtil.formatNum(d.getSeconds(),2)},
		'S+' : function(d) {return DateUtil.formatNum(d.getMilliseconds(),4)},
		'T+' : function(d) {return d.getTime()}
	},
	
	'getCurrentDateTime' : function(format) {
		var currentDateTime = new Date();
		
		for (var k in DateUtil.styleFormat) {
			if (eval(('/(' + k + ')/gi')).test(format)) {
				format = format.replace(RegExp.$1, DateUtil.formatNum(DateUtil.styleFormat[k](currentDateTime), 2));
			}
		}

		return format;
	}
}